package cn.leida.ruoyi.generator.dto;

import cn.leida.ruoyi.common.utils.bean.BeanUtils;
import cn.leida.ruoyi.generator.domain.GenTable;
import com.alibaba.fastjson2.JSONObject;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * GenTableDto
 *
 * @author liutietou
 * @since 1.0,  2020-12-26
 */
@Data
public class GenTableDto {

    private String tableName;

    private String tableComment;

    private String createTime;

    private String updateTime;

    public static List<GenTable> loadBeans(List<JSONObject> jsonList) {
        List<GenTable> beans = new ArrayList<>();
        if (jsonList == null || jsonList.isEmpty()) {
            return beans;
        }
        //  map 转对象
        for (JSONObject jsonObject : jsonList) {
            GenTableDto dto = jsonObject.toJavaObject(GenTableDto.class);
            GenTable bean = new GenTable();
            BeanUtils.copyProperties(dto, bean);
            beans.add(bean);
        }
        return beans;
    }

}
